import java.util.List;

public class Hall {
    private String hallName;
    private int rowCount;
    private int colCount;
    private Seat[][] seats;

    public Hall(String hallName, int rowCount, int colCount) {
        this.hallName = hallName;
        this.rowCount = rowCount;
        this.colCount = colCount;
        initSeats();
    }

    private void initSeats() {
        seats = new Seat[rowCount][colCount];
        for (int i = 0; i < rowCount; i++) {
            for (int j = 0; j < colCount; j++) {
                seats[i][j] = new Seat(i + 1, j + 1, false);
            }
        }
    }

    public boolean checkSeatAvailable(int row, int col) {
        if (row < 1 || row > rowCount || col < 1 || col > colCount) {
            return false;
        }
        return !seats[row - 1][col - 1].isSold();
    }

    public boolean lockSeats(List<Seat> seatsToLock) {
        for (Seat seat : seatsToLock) {
            int row = seat.getRow() - 1;
            int col = seat.getCol() - 1;
            if (row < 0 || row >= rowCount || col < 0 || col >= colCount) {
                return false;
            }
            seats[row][col].setSold(true);
        }
        return true;
    }

    public boolean unlockSeats(List<Seat> seatsToUnlock) {
        for (Seat seat : seatsToUnlock) {
            int row = seat.getRow() - 1;
            int col = seat.getCol() - 1;
            if (row < 0 || row >= rowCount || col < 0 || col >= colCount) {
                return false;
            }
            seats[row][col].setSold(false);
        }
        return true;
    }

    public String getHallName() { return hallName; }
    public int getRowCount() { return rowCount; }
    public int getColCount() { return colCount; }
}